package com.sun.enhancekafka.producer;

import org.apache.kafka.clients.producer.ProducerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

/**
 * 生产者
 */
@Component
//@EnableScheduling
public class KafkaProduceController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;


   // @Scheduled(cron = "* * * * * ?")
    public void producerr() {
        for (int i = 0; i < 10; i++) {
            kafkaTemplate.send(new ProducerRecord<String, String>("first", "hello" + i, "java" + i));
        }
    }

}
